package cz.muni.fi.hauntedhousesweb.web;

import cz.muni.fi.hauntedhouses.service.HumanService;
import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.action.UrlBinding;
import net.sourceforge.stripes.integration.spring.SpringBean;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
 
@Controller
@UrlBinding("/logout")
public class LogoutActionBean implements ActionBean {
 
    private ActionBeanContext context;
    
    
    @DefaultHandler
    public Resolution all() {
        return new ForwardResolution("/login.jsp");
    }
//	@RequestMapping(value="/welcome", method = RequestMethod.GET)
//	public String printWelcome(ModelMap model) {
// 
//		User user = (User)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
//		String name = user.getUsername();
//	
//		model.addAttribute("username", name);
//		model.addAttribute("message", "Spring Security login + database example");
//		return "hello";
// 
//	}
// 
//	@RequestMapping(value="/login", method = RequestMethod.GET)
//	public String login(ModelMap model) {
// 
//		return "login";
// 
//	}
//	
//	@RequestMapping(value="/loginfailed", method = RequestMethod.GET)
//	public String loginerror(ModelMap model) {
// 
//		model.addAttribute("error", "true");
//		return "login";
// 
//	}
//	
//	@RequestMapping(value="/logout", method = RequestMethod.GET)
//	public String logout(ModelMap model) {
// 
//		return "login";
// 
//	}

    @Override
    public void setContext(ActionBeanContext context) {
        this.context = context;
    }

    @Override
    public ActionBeanContext getContext() {
        return context;
    }
	
}